<template>
  <el-dialog title="修改工序配置" :visible.sync="show" :close-on-click-modal="false" :show-close="!btnLoading" width="800px" @closed="$refs.form.resetFields()">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
      <el-form-item prop="configId" class="hide" />
      <el-form-item prop="projectName" class="hide" />
      <el-form-item prop="buildingName" class="hide" />
      <el-form-item prop="checktypeName" class="hide" />
      <el-form-item prop="checktableName" class="hide" />
      <el-row>
        <el-col :span="12">
          <el-form-item label="工程项目" prop="projectId">{{ form.projectName }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="楼栋" prop="buildingId">{{ form.buildingName }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="阶段" prop="checktypeId">{{ form.checktypeName }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="工序" prop="checktableId">{{ form.checktableName }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="验收对象" prop="unitTypeName">{{ form.unitTypeName }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="专业类别" prop="specialTypeId">
            <el-select v-model="form.specialTypeId" placeholder="请选择" default-first-option filterable style="width: 100%">
              <el-option v-for="dict in specialTypes" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="工程师验收比例" prop="gcsPercent">
            <el-input v-model.trim.number="form.gcsPercent" placeholder="请输入工程师验收比例" :maxlength="6"><template slot="append">%</template></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="监理验收比例" prop="jlPercent">
            <el-input v-model.trim.number="form.jlPercent" placeholder="请输入监理验收比例" :maxlength="6"><template slot="append">%</template></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目总验收比例" prop="xmzPercent">
            <el-input v-model.trim.number="form.xmzPercent" placeholder="请输入项目总验收比例" :maxlength="6"><template slot="append">%</template></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目经理验收比例" prop="xmjlPercent">
            <el-input v-model.trim.number="form.xmjlPercent" placeholder="请输入项目经理验收比例" :maxlength="6"><template slot="append">%</template></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="5">
          <el-form-item label="报验是否上传附件" prop="isReqAttch"><el-switch v-model="form.isReqAttch" /></el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="备注必填标志" prop="isReqRemark"><el-switch v-model="form.isReqRemark" /></el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="是否启用" prop="isEnable"><el-switch v-model="form.isEnable" /></el-form-item>
        </el-col>
      </el-row> -->
      <el-form-item label="备注" prop="remark"><el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :maxlength="255" /></el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" :loading="btnLoading" @click="btnSubmit">确 定</el-button>
      <el-button :disabled="btnLoading" @click="show = false">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
// 修改楼栋工序配置
import { percentRule } from '@/utils/validate'
import { editFormMixin } from '@/utils/mixin'
import { getSpecialTypes } from '@/utils/dict/custom'
import { updateCheckConfig } from '@/api/qualityManage/cq'
export default {
  mixins: [editFormMixin],
  data() {
    return {
      primaryKey: 'configId',
      updateApi: updateCheckConfig,
      form: {
        configId: '',
        projectId: '',
        projectName: '',
        buildingId: '',
        buildingName: '',
        checktypeId: '',
        checktypeName: '',
        checktableId: '',
        checktableName: '',
        unitTypeName: '',
        specialTypeId: '',
        gcsPercent: 0,
        jlPercent: 0,
        xmzPercent: 0,
        xmjlPercent: 0,
        remark: ''
        // isReqAttch: false,
        // isReqRemark: false,
        // isEnable: true
      },
      rules: {
        specialTypeId: [{ required: true, message: '请选择专业类别' }],
        gcsPercent: [{ required: true, message: '请输入工程师验收比例' }, percentRule],
        jlPercent: [{ required: true, message: '请输入监理验收比例' }, percentRule],
        xmzPercent: [{ required: true, message: '请输入项目总验收比例' }, percentRule],
        xmjlPercent: [{ required: true, message: '请输入项目经理验收比例' }, percentRule]
      },
      specialTypes: [] // 专业类别
    }
  },
  created() {
    getSpecialTypes().then(res => (this.specialTypes = res))
  }
}
</script>
